# coding=utf-8
from mongoengine import *


#基础数据部分

#员工
class Staff(Document):
    name = StringField(required=True, max_length=32, unique=True)
    businessidlist = ListField(IntField(required=True, unique=True))
    password = StringField(required=True, max_length=32)
    default = StringField()

#区域类
class Area(Document):
    code = IntField(required=True)
    name = StringField(required=True)

#合作方类
class Sp(Document):
    name = StringField(required=True)

#分成信息类
class Proportion(EmbeddedDocument):
    value=StringField(required=True)
    effect = StringField(required=True,max_length=6)

#分成类
class Settlement(EmbeddedDocument):
    sp = ReferenceField(Sp)
    proportions = ListField(EmbeddedDocument(Proportion),required=True)

#业务类
class Business(Document):
    name = StringField(required=True)
    sp = ReferenceField(Sp)
    settlements = ListField(EmbeddedDocument(Settlement),required=True)

#业务数据类
class BusinessData(EmbeddedDocument):
    business = ReferenceField(Business)
    items = ListField(EmbeddedDocument(AreaData),required=True)

#月报表基础类
class MonReport(Document):
    month = StringField(max_length=6,min_length=6,required=True)
    meta = {'abstract':True}

#日报表基础类
class DayReport(Document):
    date = StringField(max_length=8,min_length=8,required=True)
    meta = {'abstract':True}

#报表数据项
class AreaData(EmbeddedDocument):
    code = StringField(required=True,unique=True)
    value = FloatField(required=True)

#分成结算数据报表
class SettleReport(MonReport):
    pass
